<template>
  <view>
    <view class="top-box">
      <!-- #ifndef H5 -->
      <view class="" style="height: 40px"></view>
      <!-- #endif -->

      <image src="https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/myBj.png" class="img-bg"></image>

      <view class="userInfo-box">
        <view class="left" v-if="isLogin">
          <image :src="userInfo.image" mode="aspectFill"></image>
          <view class="name">
            <view>
              <!-- <view class="userName">{{ userInfo.nickname }}</view> -->
              <view class="userName" v-if="userInfo.mobile">{{ hidePhoneNumber(userInfo.mobile) }}</view>
              <view class="denglu">ID:{{ parseInt(80000) + userInfo.id }}</view>
            </view>
          </view>
        </view>
        <view class="left" v-else @click.stop="$.to('/pages/my/login')">
          <image src="@/static/image/headPic.png" mode="aspectFill" style="width: 140rpx; height: 140rpx">
          </image>
          <view class="get-proto">{{$t('点击头像')}}</view>
          <view class="name">
            <view>
              <view class="userName">{{$t('请去授权')}}</view>
            </view>
          </view>
        </view>
        <view class="">
          <view class="news-btn">
            <view class="xiao" @click="$.to('/pages/my/news')">
              <u-badge type="error" :count="notice_count" :offset="[-16, 60]"></u-badge>
              <image src="../../static/image/xiaoxi.png" mode="heightFix" style="height: 40rpx"></image>
            </view>
            <view class="" @click="$.to('/pagesA/pages/my/setUp')">
              <image src="../../static/image/setup.png" mode="heightFix" style="height: 40rpx"></image>
            </view>
          </view>
          <view class="edit" @click="gotoUser">
            <image src="http://mhimg.69box.cn/kaixiang/mf.png"></image>
            <text>{{$t('编辑资料')}}</text>
          </view>
        </view>
      </view>

      <view class="jinebox">
        <view class="jinebox-info" @click="$.to('/pagesA/pages/my/currency?sta=2')">
          <image src="../../static/image/xr.png" mode="aspectFill"></image>
          <view class="text">
            <view>{{$t('幸运币')}}</view>
            <text>{{ userInfo.integral ? Number(userInfo.integral).toFixed(2) : 0 }}</text>
          </view>
          <!-- 	<view class="">
						<view >幸运币</view>
						<text>{{ userInfo.integral }}</text>
					</view> -->
        </view>
        <view class="jinebox-info" @click="$.to('/pagesA/pages/my/currency?sta=3')">
          <image src="../../static/image/y2.png" mode="aspectFill"></image>
          <view class="text">
            <view>{{$t('星石')}}</view>
            <text>{{ userInfo.integral2 ? Number(userInfo.integral2).toFixed(2) : 0 }}</text>
          </view>
        </view>
      </view>
    </view>

    <view class="fulibox">
      <view class="fulibox-left" @click="$.to('/pagesA/pages/my/qiandao')">
        <view class="fulibox-info">
          <view>{{$t('签到中心')}}</view>
          <text>{{$t('完成签到领取福利')}}</text>
        </view>
        <image src="https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/fu2.png" mode="heightFix"></image>
      </view>
      <view class="fulibox-middle"></view>
      <view class="fulibox-right" @click="sdkshow = true">
        <view class="fulibox-info">
          <view>{{$t('福利中心')}}</view>
          <text>{{$t('超多平台活动福利')}}</text>
        </view>
        <image src="../../static/image/enimg/fu1.png" mode="heightFix"></image>
      </view>
    </view>

    <view class="myOrder">
      <view class="title n-flex-row n-justify-between">
        <view>{{$t('我的订单')}}</view>
        <!-- <view class="allorder" @click="$.to('/pages/my/order?idx=0')">
				全部订单 
				<u-icon size="26" name="arrow-right"></u-icon>
				</view> -->
      </view>
      <view class="orderList n-flex-row n-justify-between">
        <view class="list" @click="$.to('/pagesA/pages/my/order?idx=0')">
          <image src="https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/order@1.png" mode=""></image>
          <view>{{$t('全部订单')}}</view>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/order?idx=1')">
          <u-badge type="error" :offset="[-10, 0]" :count="jiaoBiao.dfh ? jiaoBiao.dfh : 0"></u-badge>
          <image src="https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/order@2.png" mode=""></image>
          <view>{{$t('待发货')}}</view>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/order?idx=2')">
          <u-badge type="error" :offset="[-10, 0]" :count="jiaoBiao.yfh ? jiaoBiao.yfh : 0"></u-badge>
          <image src="https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/order@3.png" mode=""></image>
          <view>{{$t('待收货')}}</view>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/order?idx=3')">
          <image src="https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/order@4.png" mode=""></image>
          <view>{{$t('已完成')}}</view>
        </view>
      </view>
    </view>

    <view class="invite">
      <view class="invite-title">
        <view class="invite-title-left">{{$t('我的邀请')}}</view>
        <view class="invite-title-right" @click="$.to('/pagesA/pages/my/yaoqing')">
          {{$t('进入邀请')}}
          <u-icon size="20" name="arrow-right"></u-icon>
        </view>
      </view>
      <view class="invite-content">
        <image src="../../static/image/enimg/myInvite.png" mode=""></image>
        <view class="invite-content-info">
          <view class="info-item" @click="$.to('/pagesA/pages/my/currency?sta=1')">
            <view>
              {{ userInfo.team_income_sum ? Number(userInfo.team_income_sum).toFixed(2) : 0 }}
            </view>
            <text>{{$t('当前收益')}}</text>
          </view>
          <view class="info-item" @click="$.to('/pagesA/pages/my/currency?sta=1')">
            <view>
              {{ userInfo.balance ? Number(userInfo.balance).toFixed(2) : 0 }}
            </view>
            <text>{{$t('可提现收益')}}</text>
          </view>
          <view class="info-item" @click="$.to('/pagesA/pages/my/myTeam')">
            <view>
              {{ userInfo.xj_count ? userInfo.xj_count : 0 }}
            </view>
            <text>{{$t('已邀好友')}}</text>
          </view>
        </view>
      </view>
    </view>

    <view class="myapp">
      <view class="tit">{{$t('我的应用')}}</view>
      <view class="applist n-flex-row n-wrap">
        <view class="list" @click="$.to('/pagesA/pages/my/qiandao')">
          <image src="../../static/image/qian.png" mode=""></image>
          <view>{{$t('签到有奖')}}</view>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/coupon')">
          <image src="../../static/image/m9.png" mode=""></image>
          <view>{{$t('优惠券')}}</view>
          <text class="coupon_count" v-if="coupon_count > 0">{{ coupon_count }}</text>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/address')">
          <image src="../../static/image/mc.png" mode=""></image>
          <view>{{$t('地址管理')}}</view>
        </view>

        <!-- #ifdef APP-PLUS -->
        <view class="list" @click="wxKefu">
          <image src="../../static/image/m_.png" mode=""></image>
          <view>{{$t('联系客服')}}</view>
        </view>
        <!-- #endif -->
        <!-- #ifdef MP-WEIXIN -->
        <view class="list">
          <button class="list kf-button" open-type="contact">
            <image src="../../static/image/m_.png" mode=""></image>
            <view>{{$t('联系客服')}}</view>
          </button>
        </view>
        <!-- #endif -->
     <!--   <view class="list" @click="toWecom">
          <image src="../../static/image/guan.png" mode=""></image>
          <view>{{$t('企业微信')}}</view>
        </view> -->
        <view class="list" @click="$.to('/pagesA/pages/my/yaoqing')">
          <image src="../../static/image/li.png" mode=""></image>
          <view>{{$t('邀请有奖')}}</view>
        </view>
        <view class="list" @click="sdkshow = true">
          <image src="../../static/image/ma1.png" mode=""></image>
          <view>{{$t('礼包码')}}</view>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/myTeam')">
          <image src="../../static/image/friend.png" mode=""></image>
          <view>{{$t('团队管理')}}</view>
        </view>
        <view class="list" @click="$.to('/pagesA/pages/my/my_popularize')">
          <!-- <view class="list" @click="$.to('/pagesA/pages/my/my_popularize')" > -->
          <image src="../../static/image/ma.png" mode=""></image>
          <view>{{$t('我的推广')}}</view>
        </view>
      </view>
    </view>

    <u-popup v-model="sdkshow" mode="center" border-radius="16">
      <view class="cdkbox">
        <view class="tit">{{$t('礼包码')}}</view>
        <u-input v-model="sdk" input-align="center" :border="true" :placeholder="$t('请输入礼包码')" />
        <button @click="duihuan">{{$t('确定')}}</button>
      </view>
    </u-popup>
    <u-popup v-model="showBindTel" mode="center">
      <view class="showBindTel-view">
        <view class="showBindTel">{{$t('请绑定手机号')}}</view>
        <view class="row">
          <u-field v-model="Bind.phone" type="number" :label-width="0" maxlength="11" :placeholder="$t('请输入手机号')"></u-field>
        </view>

        <view class="row row-code">
          <u-field v-model="Bind.num" type="number" :label-width="0" :placeholder="$t('请输入验证码')" style="width: 100%">
            <text class="huoqu" slot="right" @click="getCode">{{ codeText }}</text>
          </u-field>
          <u-verification-code ref="uCode" @change="codeChange" change-text="xs"></u-verification-code>
        </view>

        <view class="row-btn">
          <view class="rrow-btn-left" @click="showBindTel = false">{{$t('取消')}}</view>
          <view class="row-btn-right" @click="bindTel">{{$t('绑定')}}</view>
        </view>
      </view>
    </u-popup>
    <kefu :isShow="kfshow" ref="child" @cusEvent="hide"></kefu>
    <uni-popup ref="popupLimits" type="top" heigth="200" :is-mask-click="false" @maskClick="popupClcik">
      <view class="qweqwe">
        <view>{{$t('申请手机或耳机的麦克风权限')}}</view>
        <view>{{$t('申请相册权限')}}</view>
      </view>
    </uni-popup>
    <!-- <u-tabbar v-model="current" :list="mhstatus == 1 ? tabbar1 : tabbar " :mid-button="box_view"></u-tabbar> -->
	<!-- <u-tabbar v-model="current" :list="tabbar" :mid-button="box_view"></u-tabbar> -->
	<u-tabbar v-model="current" :list="mhstatus == 1 ? tabbar1 : tabbar " :mid-button="box_view"></u-tabbar>
  </view>
</template>

<script>
import kefu from "@/components/kefu.vue";
import { box_view } from "@/utils/keyControl.js";
import { tabbar } from "@/common/tabbar.js";
// #ifdef APP-PLUS
var qiyuModule = uni.requireNativePlugin("Netease-QiyuModule");
const modal = uni.requireNativePlugin("modal");
import { qy_appKey } from "@/utils/keyControl.js";
// #endif
export default {
  data() {
    return {
		mhstatus:uni.getStorageSync("mhstatus"), //版本控制开关
      current: 5,
      // tabbar: tabbar,
      codeText: this.$t('获取验证码'),
      background: {
        backgroundColor: "",
      },
      isLogin: false,
      userInfo: {},
      sdkshow: false,
      sdk: "",
      count: 0, //消息角标
      kfshow: false,
      jiaoBiao: "",
      showBindTel: false, // 是否展示绑定手机号
      Bind: {
        phone: "",
        num: "",
      },
      coupon_count: 0, // 优惠券总数
      notice_count: 0, // 未读消息总数
      box_view: false,
    };
  },
  computed: {
	  tabbar() {
	  		return [{
	  				id: 0,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab1.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab2.png",
	  				text: this.$t("首页"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/home",
	  			},
	  			{
	  				id: 1,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab3.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab4.png",
	  				text: this.$t("商城"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/mall",
	  			},
	  			// {
	  			// 	id: 5,
	  			// 	iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab5.png",
	  			// 	selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab6.png",
	  			// 	text: this.$t("盒子"),
	  			// 	midButton: true,
	  			// 	customIcon: false,
	  			// 	pagePath: "/pages/tabBar/old_home",
	  			// },
	  			{
	  				id: 2,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab7.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab8.png",
	  				text: this.$t("仓库"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/cangku",
	  			},
	  			{
	  				id: 3,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab9.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab10.png",
	  				text: this.$t("我的"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/my",
	  			},
	  		]
	  	},
	  	tabbar1() {
	  		return [{
	  				id: 0,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab1.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab2.png",
	  				text: this.$t("首页"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/home",
	  			},
				{
					id: 1,
					iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab3.png",
					selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab4.png",
					text: this.$t("商城"),
					customIcon: false,
					pagePath: "/pages/tabBar/mall",
				},
	  			{
	  				id: 2,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab7.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab8.png",
	  				text: this.$t("仓库"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/cangku",
	  			},
	  			{
	  				id: 3,
	  				iconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab9.png",
	  				selectedIconPath: "https://v3mh6.oss-cn-beijing.aliyuncs.com/51api/tab10.png",
	  				text: this.$t("我的"),
	  				customIcon: false,
	  				pagePath: "/pages/tabBar/my",
	  			},
	  		]
	  	}
	  
  },
  components: {
    kefu,
    newId() {
      //return parseInt(80000) + this.userInfo.id;
      return parseInt(80000) + this.userInfo.id;
    },
  },
  onLoad() {
    this.box_view = box_view;
    uni.$on("updataUser", () => {
      if (uni.getStorageSync("user")) {
        this.getUser();
      } else {
        this.userInfo = {};
        this.getLogin();
      }
    });
  },
  onShow() {
    this.getLogin();
    let userInfo = uni.getStorageSync("user");
    if (uni.getStorageSync("user")) {
      this.getUser();
      this.getNum();
      if (!userInfo.mobile) {
        this.showBindTel = true;
      }
    } else {
	    uni.redirectTo({
	    	url:'../../pages/my/login'
	    })
	}

    // #ifdef APP-PLUS
    this.initSetUserInfo(userInfo);
    // this.getMessageCount()
    // #endif
  },
  onUnload() {
    uni.$off("updataUser");
  },
  methods: {
    hidePhoneNumber(phoneNumber) {
      return phoneNumber.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
    },
    //获取ip
    getIp() {
      this.$http({
        url: "api/Ios/get_ip",
      })
        .then((res) => {
          if (res.data.code == 1) {
            //res.data.data.ip
            return res.data.data.clear;
          }
        })
        .catch((err) => { });
    },
    /* 初始化七鱼 */
    initSetUserInfo() {
      // let userInfo = uni.getStorageSync("user");
      const { id, username, mobile, image, create_time, update_time } =
        userInfo;
      qiyuModule.initSdk({
        appKey: qy_appKey,
        appName: "叮当盲盒",
        pkCerName: "PushKit推送证书名；对应云信的pkCername",
      });
      qiyuModule.setUserInfo(
        {
          userId: id || this.getIp(),
          data: JSON.stringify([
          {
              key: "real_name",
              value: username ? username : '',
            },
            {
              key: "mobile_phone",
              hidden: true,
              value: mobile ? mobile : '',
            },

            {
              key: "avatar",
              value: image ? image : 'https://qiyukf.com/def_avatar.png'
            },
            {
              index: 5,
              key: "reg_date",
              label: "注册日期",
              value: create_time ? create_time : '',
            },
            {
              index: 6,
              key: "last_login",
              label: "上次登录时间",
              value: update_time ? update_time : '',
            },
          ]),
        },
        (ret) => {
          if (ret.code == 200) {
            // modal.toast({
            // 	message: '成功',
            // 	duration: 1.5
            // });
          } else {
            // modal.toast({
            // 	message: '失败' + JSON.stringify(ret.errMsg),
            // 	duration: 1.5
            // });
          }

          console.log("js打印" + JSON.stringify(ret));
        }
      );
      qiyuModule.updateOptions(
        {
          isPullMessageFromServer: false,
          uiCustomization: {
            hideLeftAvatar: false,
            isShowTitleAvatar: true,
            hideRightAvatar: false,
            inputTextColor: "#ff5500",
          },
        },
        (url) => {
          //点击url的回调
          plus.runtime.openWeb(url);
        }
      );
      qiyuModule.setFinishPageSwitch(true);
      qiyuModule.setPermissionCallback((retCallback) => {
        //麦克风
        let value1 = uni.getStorageSync("is_KEFU_RECORD_AUDIO");
        if (value1 != 1) {
          this.$refs.popupLimits.open();
        }
        plus.android.requestPermissions(
          [
            "android.permission.RECORD_AUDIO",
            "android.permission.MODIFY_AUDIO_SETTINGS",
          ],
          function (e) {
            if (e.deniedAlways.length > 0) {
              //权限被永久拒绝
              // 弹出提示框解释为何需要权限，引导用户打开设置页面开启
              console.log("权限被永久拒绝" + e.deniedAlways.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_RECORD_AUDIO", 2);
            }
            if (e.deniedPresent.length > 0) {
              //权限被临时拒绝
              // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限
              console.log("权限被临时拒绝" + e.deniedPresent.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_RECORD_AUDIO", 0);
            }
            if (e.granted.length > 0) {
              //权限被允许
              console.log("权限被允许" + e.granted.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_RECORD_AUDIO", 1);
            }
          },
          function (e) {
            console.log("Request Permissions error:" + JSON.stringify(e));
            uni.showToast({
              title: "Request Permissions error:" + JSON.stringify(e),
            });
          }
        );
        //相机 相册
        let value2 = uni.getStorageSync("is_KEFU_CAMERA");
        if (value2 != 1) {
          this.$refs.popupLimits.open();
        }
        plus.android.requestPermissions(
          [
            "android.permission.CAMERA",
            "android.permission.READ_EXTERNAL_STORAGE",
          ],
          function (e) {
            if (e.deniedAlways.length > 0) {
              //权限被永久拒绝
              // 弹出提示框解释为何需要权限，引导用户打开设置页面开启
              console.log("权限被永久拒绝" + e.deniedAlways.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_CAMERA", 2);
            }
            if (e.deniedPresent.length > 0) {
              //权限被临时拒绝
              // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限
              console.log("权限被临时拒绝" + e.deniedPresent.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_CAMERA", 0);
            }
            if (e.granted.length > 0) {
              //权限被允许
              console.log("权限被允许" + e.granted.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_CAMERA", 1);
            }
          },
          function (e) {
            console.log("Request Permissions error:" + JSON.stringify(e));
            uni.showToast({
              title: "Request Permissions error:" + JSON.stringify(e),
            });
          }
        );
        //文件存储
        let value3 = uni.getStorageSync("is_KEFU_FILE");
        if (value3 != 1) {
          this.$refs.popupLimits.open();
        }
        plus.android.requestPermissions(
          [
            "android.permission.MANAGE_EXTERNAL_STORAGE",
            "android.permission.WRITE_EXTERNAL_STORAGE",
          ],
          function (e) {
            if (e.deniedAlways.length > 0) {
              //权限被永久拒绝
              // 弹出提示框解释为何需要权限，引导用户打开设置页面开启
              console.log("权限被永久拒绝" + e.deniedAlways.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_FILE", 2);
            }
            if (e.deniedPresent.length > 0) {
              //权限被临时拒绝
              // 弹出提示框解释为何需要权限，可再次调用plus.android.requestPermissions申请权限
              console.log("权限被临时拒绝" + e.deniedPresent.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_FILE", 0);
            }
            if (e.granted.length > 0) {
              //权限被允许
              console.log("权限被允许" + e.granted.toString());
              this.$refs.popupLimits.close();
              uni.setStorageSync("is_KEFU_FILE", 1);
            }
          },
          function (e) {
            console.log("Request Permissions error:" + JSON.stringify(e));
            uni.showToast({
              title: "Request Permissions error:" + JSON.stringify(e),
            });
          }
        );
      });
    },
    //企业微信客服
    wxKefu() {
      this.$http({
        url: "api/member/get_weixin_state",
        data: {},
      })
        .then((res) => {
          if (res.data.code == 1) {
            let obj = res.data.data;
            if (obj.weixin_kefu == 1) {
              uni.navigateTo({
                url: "/pagesA/pages/my/wecom",
              });
            } else {
              this.startQiyu();
            }
          } else {
            this.$tip.tip(res.data.msg);
          }
        })
        .catch((err) => { });
    },
    // 联系客服
    startQiyu() {
      qiyuModule.openServiceActivity({
        title: "官方客服",
        source: {
          title: "官方客服",
          robotId: 5395052,
        },
        openMode: "push",
      });
    },
    popupClcik() {
      this.$refs.popupLimits.close();
      this.startQiyu();
    },
    codeChange(text) {
      // this.codeText = text;
    },
    getCode() {
      if (this.$refs.uCode.canGetCode) {
        if (this.$tip.phoneReg.test(this.Bind.phone) == false) {
          this.$tip.tip(this.$t("请填写正确的手机号"));
          return;
        }
        uni.showLoading({
          title: "正在获取验证码",
        });
        this.$http({
          url: "api/login/send_sms",
          data: {
            event: "login",
            mobile: this.Bind.phone,
          },
        })
          .then((res) => {
            if (res.data.code == 1) {
              uni.hideLoading();
              // 通知验证码组件内部开始倒计时
              this.$refs.uCode.start();
            } else {
              this.$tip.tip(res.data.msg);
            }
          })
          .catch((err) => { });
      } else {
        this.$u.toast("倒计时结束后再发送");
      }
    },
    bindTel() {
      this.$http({
        url: "api/member/bind_mobile",
        data: {
          mobile: this.Bind.phone,
          code: this.Bind.num,
        },
      })
        .then((res) => {
          if (res.data.code == 1) {
            let userInfo = uni.getStorageSync("user");
            userInfo.mobile = this.Bind.phone;
            uni.setStorageSync("user", userInfo);
            this.$u.toast("绑定成功");
            this.showBindTel = false;
          } else {
            this.$tip.tip(res.data.msg);
          }
        })
        .catch((err) => { });
    },
    gotoUser() {
      uni.navigateTo({
        url: "/pagesA/pages/my/userInfo",
      });
    },
    toWecom() {
      if (this.isLogin) {
        uni.navigateTo({
          url: "/pagesA/pages/my/wecom",
        });
      } else {
        uni.showToast({
          title: this.$t('登录提示'),
          icon: "none",
        });
      }
    },
    //获取各类订单状态数字
    getNum() {
      this.$http({
        url: "api/order/get_order_status_count",
      })
        .then((res) => {
          if (res.data.code == 1) {
            var data = res.data.data;
            this.jiaoBiao = {
              dfh: data.dfh,
              yfh: data.dsh,
            };
          }
        })
        .catch((err) => { });
    },
    hide() {
      this.kfshow = false;
    },

    // 礼包码转换
    duihuan() {
      if (this.sdk == "") {
        this.$tip.tip(this.$t('请填写兑换码'));
        return;
      }
      this.$http({
        url: "api/member/cdkey",
        data: {
          kahao: this.sdk,
        },
      })
        .then((res) => {
          console.log(res);
          if (res.data.code == 1) {
            this.$tip.tip(res.data.msg);
            this.sdkshow = false;
            this.getUser();
          } else {
            this.$tip.tip(res.data.msg);
          }
        })
        .catch((err) => { });
    },
    getLogin() {
      if (uni.getStorageSync("user")) {
        this.isLogin = true;
      } else {
        this.isLogin = false;
      }
    },
    getUser() {
      if (!uni.getStorageSync("user")) {
        return;
      }
      this.$http({
        url: "api/member/get_user_info",
      })
        .then((res) => {
          if (res.data.code == 1) {
            this.getLogin();
            this.userInfo = res.data.data;
            this.coupon_count = res.data.data.coupon_count;
            this.notice_count = res.data.data.notice_count;
            this.userInfo = res.data.data;
            uni.setStorageSync("user", res.data.data);
          }
        })
        .catch((err) => { });
    },
    sc() {
      uni.switchTab({
        url: "/pages/tabBar/mall",
      });
      // setTimeout(() => {
      // 	uni.$emit('sc', 0)
      // }, 300)
    },
    mh() {
      uni.switchTab({
        url: "/pages/tabBar/cangku",
      });
      setTimeout(() => {
        uni.$emit("sc", 0);
      }, 300);
    },
  },
};
</script>

<style lang="scss" scope>
page {
  background-color: rgb(239, 243, 250);
}

.top-box {
  width: 750rpx;
  height: 480rpx;
  padding-top: 44rpx;
  box-sizing: border-box;
  position: relative;

  .img-bg {
    width: 750rpx;
    height: 480rpx;
    position: absolute;
    top: 0;
  }

  .userInfo-box {
    width: 690rpx;
    height: 60rpx;
    position: absolute;
    box-sizing: border-box;
    left: 30rpx;
    top: 196rpx;
    display: flex;
    justify-content: space-between;

    .left {
      display: flex;
      align-items: center;
      position: relative;
      max-width: 70%;

      image {
        width: 120rpx;
        height: 120rpx;
        border-radius: 50%;
        margin-right: 30rpx;
        flex-shrink: 0;
      }

      .get-proto {
        position: absolute;
        width: 140rpx;
        text-align: center;
        font-size: 22rpx;
        color: #fff;
        text-align: center;
      }

      .denglu {
        color: #fff;
        font-size: 25rpx;
        margin-top: 10rpx;
      }

      .userName {
        color: #fff;
        font-weight: bold;
        font-size: 32rpx;
      }
    }

    .edit {
      display: flex;
      align-items: center;
      border-radius: 60rpx;
      height: 60rpx;
      border: 1rpx solid #000;
      padding: 0 20rpx;
      margin-top: 30rpx;
    }

    .edit image {
      width: 36rpx;
      height: 36rpx;
    }
  }

  .jinebox {
    width: 690rpx;
    height: 150rpx;
    position: absolute;
    box-sizing: border-box;
    left: 30rpx;
    bottom: 0rpx;
    background-color: #fff;
    border-radius: 16rpx;
    overflow: hidden;
    display: flex;
    justify-content: space-around;

    .jinebox-info {
      width: 100%;
      text-align: center;
      font-size: 26rpx;
      color: #000;
      display: flex;
      justify-content: center;
      align-items: center;

      image {
        width: 50rpx;
        height: 50rpx;
        margin-right: 20rpx;
      }

      .text {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
      }

      view {
        font-weight: bold;
      }

      text {
        margin-top: 6rpx;
      }
    }
  }
}

.fulibox {
  height: 150rpx;
  width: 690rpx;
  box-sizing: border-box;
  margin: 30rpx auto;
  border-radius: 16rpx;
  background-color: #fff;
  display: flex;
  align-items: center;

  &-left,
  &-right {
    width: 334rpx;
    height: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
	position: relative;

    .fulibox-info {
      flex-shrink: 0;
	  left: 20rpx;
      width: 230rpx;
      text-align: left;
      display: flex;
      flex-direction: column;
      justify-content: center;
	  position: absolute;

      view {
        font-size: 30rpx;
        font-weight: bold;
      }

      text {
        font-size: 20rpx;
        color: rgb(160, 74, 255);
        margin-top: 12rpx;
      }
    }

    image {
      height: 76rpx;
      flex-shrink: 0;
	  position: absolute;
	  right: 20rpx;
    }
  }

  &-middle {
    width: 2rpx;
    height: 80rpx;
    background-color: #ddd;
  }
}

.myOrder {
  height: 200rpx;
  width: 690rpx;
  box-sizing: border-box;
  margin: 30rpx auto;
  border-radius: 16rpx;
  background-color: #fff;
  padding: 20rpx 20rpx 30rpx;

  .title {
    font-size: 30rpx;
    font-weight: bold;

    .allorder {
      font-size: 26rpx;
      color: #999;

      .u-icon {
        margin-left: 16rpx;
      }
    }
  }

  .orderList {
    margin-top: 20rpx;
    padding: 0 20rpx;
    box-sizing: border-box;
  }

  .orderList .list {
    text-align: center;
    position: relative;
    font-size: 20rpx;
  }

  .orderList image,
  .myapp .list image {
    width: 55rpx;
    height: 55rpx;
  }
}

.invite {
  height: 270rpx;
  width: 690rpx;
  box-sizing: border-box;
  margin: 0rpx auto;
  border-radius: 16rpx;
  background-color: #fff;
  padding: 20rpx 30rpx 30rpx;

  .invite-title {
    display: flex;
    justify-content: space-between;
    align-items: center;

    &-left {
      font-size: 30rpx;
      font-weight: bold;
    }

    &-right {
      font-size: 22rpx;
      height: 50rpx;
      width: 150rpx;
      line-height: 50rpx;
      text-align: center;
      background-color: rgba(160, 74, 255, 0.6);
      border-radius: 25rpx;
      color: #fff;

      .u-icon {
        margin-left: 6rpx;
      }
    }
  }

  .invite-content {
    display: flex;
    align-items: center;
    margin-top: 20rpx;

    image {
      height: 140rpx;
      width: 240rpx;
      flex-shrink: 0;
    }

    &-info {
      display: flex;
      justify-content: space-between;
      width: 100%;
      text-align: center;
    }

    .info-item {
      width: 100%;

      view {
        font-size: 34rpx;
        font-weight: bold;
      }

      text {
        font-size: 22rpx;
        margin-top: 16rpx;
        color: #999;
      }
    }
  }
}

.myapp {
  // height: 270rpx;
  width: 690rpx;
  box-sizing: border-box;
  margin: 30rpx auto;
  border-radius: 16rpx;
  background-color: #fff;
  padding: 20rpx 30rpx 30rpx;

  .tit {
    font-size: 30rpx;
    font-weight: bold;
  }

  .list {
    margin-top: 30rpx;
    text-align: center;
    width: 25%;
    font-size: 28rpx;
    line-height: 1.5;
    padding: 0;
    padding: 10rpx;
    position: relative;

    view {
      font-size: 24rpx;
      margin-top: 10rpx;
      color: #888;
    }

    .coupon_count {
      background-color: #fa3534;
      display: inline-block;
      height: 19px;
      width: 19px;
      line-height: 19px;
      border-radius: 9px;
      text-align: center;
      color: #fff;
      font-size: 12px;
      position: absolute;
      top: -10rpx;
      right: 22rpx;
    }
  }

  .list image {
    width: 45rpx;
    height: 45rpx;
  }

  .kf-button {
    display: inline;
    background-color: transparent;
    border: none;
    margin: unset;
    padding: unset;
    border-color: transparent;
  }

  button::after {
    border: none;
  }
}

.cdkbox {
  width: 500rpx;
  background-color: #fff;
  padding: 30rpx;
  box-sizing: border-box;

  .tit {
    text-align: center;
    margin-bottom: 35rpx;
  }

  .inp {
    border-radius: 16rpx;
    border: 1rpx solid #333;
    height: 60rpx;
  }

  button {
    border-radius: 8rpx;
    color: #fff;
    background-color: #00e1db;
    height: 70rpx;
    line-height: 70rpx;
    margin-top: 25rpx;
    font-size: 28rpx;
  }
}

.kefu {
  background: none;
}

button::after {
  border: none;
}

.news-btn {
  display: flex;
  justify-content: flex-end;
  position: absolute;
  top: -30rpx;
  width: 190rpx;
}

.news-btn image {
  margin-left: 30rpx;
}

.showBindTel-view {
  width: 600rpx;
  height: auto;
  background: #ffffff;
  border-radius: 20rpx;
  padding: 40rpx 50rpx;
  box-sizing: border-box;

  .showBindTel {
    font-size: 32rpx;
    font-weight: 500;
    color: #333333;
    text-align: center;
  }

  .u-field {
    background: #f5f5f5;
    border-radius: 20rpx;
  }

  .row {
    margin-top: 30rpx;
  }

  .row-btn {
    display: flex;
    width: 80%;
    justify-content: space-between;
    text-align: center;
    margin: 0 auto;
    margin-top: 30rpx;

    view {
      width: 170rpx;
      height: 70rpx;
      background: #ffffff;
      border-radius: 35rpx;
      border: 1rpx solid #979797;
      text-align: center;
      line-height: 70rpx;
    }

    &-right {
      color: #ffffff;
      background: #7942e8 !important;
    }
  }
}

.row-code {
  width: 100%;
}

.qweqwe {
  background-color: #fff;
  width: 100%;
  color: #000;
  margin-top: 25%;
  padding: 20rpx;
  box-sizing: border-box;
}
</style>
